package com.sky.loveshop.config;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author xcy
 * @version V1.0
 * @description
 * @date 2024/10/30 21:34
 */
@Component
public class WeChatMiniConfig {

    @Value("${wx.ma.appId}")
    private String maAppId;

    @Value("${wx.ma.appSecret}")
    private String maAppSecret;

    @Value("${wx.ma.msgDataFormat}")
    private String msgDataFormat;

    @Bean
    public WxMaService wxMaService() {
        WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
        config.setAppid(maAppId);
        config.setSecret(maAppSecret);
        config.setMsgDataFormat(msgDataFormat);

        WxMaService service = new WxMaServiceImpl();
        service.setWxMaConfig(config);
        return service;
    }

}
